current version 1.3 - 14th November 2017
| version | date | comment |
|---|---|---|
| 1.0 | 15/Sep/2008 | Original code |
| 1.1 | 17/Jun/2013 | Check for proper conversion from string to number |
| 1.2 | 24/Oct/2017 | Added TabToSpace function |
| 1.3 | 14/Nov/2017 | Added ReplaceChar |
license: GNU GPL http://www.gnu.org/licenses/
This file is part of
MOSAICO -- MOdular library for raSter bAsed hydrologIcal appliCatiOn.
Copyright (C) 2011 Giovanni Ravazzani
Module for simple string manipulations
References and Credits: Adapted from flibs library http://flibs.sourceforge.net written by Arjen Markus and string utilities http://www.gbenthien.net/strings/index.html written by Dr. George Benthien
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=26), | private, | parameter | :: | lower | = | 'abcdefghijklmnopqrstuvwxyz' | |
| character(len=26), | private, | parameter | :: | upper | = | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' |
Converts a double precision number in a string Arguments: number number to be converted Result: string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=double), | intent(in) | :: | number | |||
| character(len=*), | intent(in), | optional | :: | fmt |
Converts a real number in a string Arguments: number number to be converted Result: string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=float), | intent(in) | :: | number | |||
| character(len=*), | intent(in), | optional | :: | fmt |
Converts a long integer number in a string Arguments: number number to be converted Result: string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=long), | intent(in) | :: | number | |||
| character(len=*), | intent(in), | optional | :: | fmt |
Converts a short integer number in a string Arguments: number number to be converted Result: string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=short), | intent(in) | :: | number | |||
| character(len=*), | intent(in), | optional | :: | fmt |
char is replaced with rep
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*) | :: | string | ||||
| character(len=1) | :: | char | ||||
| character(len=1) | :: | rep |
Converts multiple spaces and tabs to single spaces; deletes control characters; removes initial spaces. Arguments: string String to be treated Result: String compacted
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*) | :: | string |
Return a string that has all characters in reverse order Arguments: string String to be reversed Result: Reversed string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*) | :: | string |
Converts number string to a double precision real number Arguments: string String to be converted Result: double precision real number
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | |||
| logical, | intent(out), | optional | :: | error |
Converts number string to a real number Arguments: string String to be converted Result: float number
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | |||
| logical, | intent(out), | optional | :: | error |
Converts number string to a long integer Arguments: string String to be converted Result: long integer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | |||
| logical, | intent(out), | optional | :: | error |
! Description: Return a string that has all letters in lower case Arguments: string String to be treated Result: String with letters turned into lower case
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*) | :: | string |
Converts number string to a short integer Arguments: string String to be converted Result: short integer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | |||
| logical, | intent(out), | optional | :: | error |
Return a string that has all letters in upper case Arguments: string String to be treated Result: String with letters turned into upper case
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*) | :: | string |
Tab character is substituted by one blank character Arguments: string String to be processed Result: processed string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*) | :: | string |
Converts a double precision number in a string Arguments: number number to be converted Result: string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=double), | intent(in) | :: | number | |||
| character(len=*), | intent(in), | optional | :: | fmt |
Converts a real number in a string Arguments: number number to be converted Result: string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=float), | intent(in) | :: | number | |||
| character(len=*), | intent(in), | optional | :: | fmt |
Converts a long integer number in a string Arguments: number number to be converted Result: string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=long), | intent(in) | :: | number | |||
| character(len=*), | intent(in), | optional | :: | fmt |
Converts a short integer number in a string Arguments: number number to be converted Result: string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=short), | intent(in) | :: | number | |||
| character(len=*), | intent(in), | optional | :: | fmt |
Finds the first instance of a character from 'delims' in the the string 'string'. The characters before the found delimiter are output in 'before'. The characters after the found delimiter are output in 'string'. The optional output character 'sep' contains the found delimiter. Arguments: string String to be treated Result: The characters before the found delimiter, the remainder is output in string
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | delims | |||
| character(len=*), | intent(inout) | :: | string | |||
| character(len=*), | intent(out) | :: | before | |||
| character(len=*), | intent(out), | optional | :: | sep |
It is often useful to represent a text as a list of tokens.
The process of breaking a text up into its constituent tokens is known
as tokenization. The subroutine parses the string in input into arguments
args(1), ..., args(nargs) based on the delimiters contained in the string
delims. Preceding a delimiter in string by a backslash \ makes this
particular instance not a delimiter.
The integer output variable nArgs contains the number of arguments found.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | string | |||
| character(len=*), | intent(in) | :: | delims | |||
| character(len=*), | POINTER | :: | args(:) |
local copy of string to tokenize |
||
| integer(kind=short), | intent(out) | :: | nArgs |